
package com.shangsi.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * 监听项目的启动和停止
 * @author dzd
 * @date 2021-12-12
 */
public class UserListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        ServletContext servletContext = servletContextEvent.getServletContext();
        //这里也可以给容器添加组件
        //servletContext.addFilter()
        //启动初始化
        System.out.println("UserListener contextInitialized------------------");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        //停止
        System.out.println("UserListener contextDestroyed--------------------");
    }
}
